/***************************************************************************
 创建者：华磊
 开始时间：         : 2017.02.13
 copyright            : (C) 深圳市华友高科有限公司
 修改说明：（每次有修改就添加一条，带有 修改人，修改时间，修改描述）

 ***************************************************************************
 *   码垛指令视窗
*                                                                         *
 ***************************************************************************/
#include "palletparametersettingview.h"
#include "ui_palletparametersettingview.h"
#include <QMessageBox>
#include <QDebug>
#include "instructionEnum.h"
#include "../CommunicateDelegate/globaldata.h"
#include "hmicommondefine.h"
#include "../CommunicateDelegate/moveoperation.h"
#define D_APPROACH_DEFAULT_SIZE 8
#define D_RETURN_DEFAULT_SIZE 8
#define D_STYLE_DEFAULT_SIZE 24
#define D_PATH_DEFAULT_SIZE 8


PalletParameterSettingView::PalletParameterSettingView(int styleId, GlobalData *globalDataIn,
                                                       MoveOperation *moveOperationIn,
                               CommunicateNormalDelegate *communicateNormalIn, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::PalletParameterSettingView)
{
    communicateNormal=communicateNormalIn;
    globalData=globalDataIn;
    moveOperation=moveOperationIn;

    ui->setupUi(this);
    setWindowFlags(Qt::FramelessWindowHint);
    setStyleSheet("background-color:white;");
    //    setGeometry(70,128,460,595);
    move(0,0);
    setTableText();
    intervalOnPicture = "border-width:0px;border-style:outset;"
                                               "image:url(/agvwork/AgvHmi/baseBag/hmiProject/resources/instruction/PalletInstructionRes/moveON.png);";
    intervalOffPicture = "border-width:0px;border-style:outset;"
                                                "image:url(/agvwork/AgvHmi/baseBag/hmiProject/resources/instruction/PalletInstructionRes/moveOFF.png);";

//    stackStylePointInfoView = new StackStylePointInfoView(styleId,parent);
//    stackStylePointInfoView->hide();
//    approachPointView = new ApproachPointView(styleId,parent);
//    approachPointView->hide();
//    fleePointView = new FleePointView(styleId,parent);
//    fleePointView->hide();
//    stackPointView = new StackPointView(styleId,parent);
//    stackPointView->hide();
//    showPointInfoView = new ShowPointInfoView(styleId,parent);
//    showPointInfoView->hide();
    ui->comboBox_FstyleRow->clear();
    for(int i=0;i<D_STYLE_DEFAULT_SIZE;i++)
    {
        ui->comboBox_FstyleRow->insertItem(i,QString::number(i+1));
    }

    ui->RowIntervalValue_lineEdit->setEnabled(false);
    ui->ColumnIntervalValue_lineEdit->setEnabled(false);
    ui->LayerIntervalValue_lineEdit->setEnabled(false);

    initialDisplayStyle(styleId);


//    connect(stackStylePointInfoView, SIGNAL(recordPoint_signal(int,int)),this, SLOT(recordPointSlot(int,int)));
//    connect(stackStylePointInfoView, SIGNAL(moveToPointSignal(int,int,int)),this, SLOT(moveToPointSlot(int,int,int)));
//    connect(stackStylePointInfoView, SIGNAL(moveToPointFinish()),this, SLOT(moveToPointFinishSlot()));
//    connect(stackStylePointInfoView, SIGNAL(showPointInfo(int)),this, SLOT(showPointInfoSlot(int)));
//    connect(stackStylePointInfoView, SIGNAL(stackStylePointPage_signal(int)), this, SLOT(stackStylePointPage_slot(int)));

//    connect(approachPointView, SIGNAL(recordPoint_signal(int,int)),this, SLOT(recordPointSlot(int,int)));
//    connect(approachPointView, SIGNAL(moveToPointSignal(int,int,int)),this, SLOT(moveToPointSlot(int,int,int)));
//    connect(approachPointView, SIGNAL(moveToPointFinish()),this, SLOT(moveToPointFinishSlot()));
//    connect(approachPointView, SIGNAL(showPointInfo(int)),this, SLOT(showPointInfoSlot(int)));
//    connect(approachPointView, SIGNAL(approchPointViewPage_signal(int)), this, SLOT(approchPointViewPage_slot(int)));

//    connect(fleePointView, SIGNAL(recordPoint_signal(int,int)),this, SLOT(recordPointSlot(int,int)));
//    connect(fleePointView, SIGNAL(moveToPointSignal(int,int,int)),this, SLOT(moveToPointSlot(int,int,int)));
//    connect(fleePointView, SIGNAL(moveToPointFinish()),this, SLOT(moveToPointFinishSlot()));
//    connect(fleePointView, SIGNAL(showPointInfo(int)), this, SLOT(showPointInfoSlot(int)));
//    connect(fleePointView, SIGNAL(fleetPointViewPage_signal(int)), this, SLOT(fleetPointViewPage_slot(int)));

//    connect(stackPointView, SIGNAL(recordPoint_signal(int,int)),this, SLOT(recordPointSlot(int,int)));
//    connect(stackPointView, SIGNAL(moveToPointSignal(int,int,int)),this, SLOT(moveToPointSlot(int,int,int)));
//    connect(stackPointView, SIGNAL(moveToPointFinish()),this, SLOT(moveToPointFinishSlot()));
//    connect(stackPointView, SIGNAL(showPointInfo(int)),this, SLOT(showPointInfoSlot(int)));
//    connect(stackPointView, SIGNAL(stackPointViewPage_signal(int)), this, SLOT(stackPointViewPage_slot(int)));

}

void PalletParameterSettingView::initialDisplayStyle(int styleId)
{
    switch (styleId) {
    case 1:
        ui->pushButton_return->setGeometry(10,400,70,40);
        ui->pushButton_changeConfig->setGeometry(360,400,70,40);
        break;
    default:
        break;
    }
}

void PalletParameterSettingView::showPointInfo(QString comment, PointPro showPointPro)
{
    ui->point_label->setText(comment);
    QString n1;
    int type = showPointPro.jointFlag;
    switch(type)
    {
        case EM_CF_DEG_TYPE:
            n1=tr("关节");
            break;
        case EM_CF_WORLD_TYPE:
            n1=tr("笛卡尔");
            break;
    default:
            break;
    }

    // pallet pointNum 未写入
//    showPointPro.pointNum = showPointNum;

    //model->reset();
    model->item(0,1)->setText(n1);
    //model->item(1,1)->setText( QString::number(showPointPro.pointNum));
    model->item(1,1)->setText( "");
    model->item(2,1)->setText( QString::number(showPointPro.groupNum));
    model->item(3,1)->setText( QString::number(showPointPro.ufValue));
    model->item(4,1)->setText( QString::number(showPointPro.utValue));
    model->item(5,1)->setText( tr(showPointPro.configString.data()));

    int rowNum = 5;

    int size=showPointPro.positionValue.size();
    for(int i=0;i<size;i++)
    {
        QString line=QString::number(showPointPro.positionValue[i]);
        if(EM_CF_DEG_TYPE == type)
        {
            model->item(6+i,0)->setText(tr("轴值:J")+QString::number(i+1));
            model->item(6+i,1)->setText(line);
        }
        else
        {
            if(i<6)
            {
                model->item(6+i,0)->setText(sixAxisName[i]);
                model->item(6+i,1)->setText(line);
            }
        }

        rowNum++;
    }



    for(int i=0;i<showPointPro.extPositionValue.size();i++)
    {
        rowNum++;//+1
        //qDebug()<<rowNum<<" *** "<<pointProMo.extPositionValue[i];
        model->item(rowNum,0)->setText(tr("外部轴值:E")+QString::number(i+1));
        model->item(rowNum,1)->setText(QString::number(showPointPro.extPositionValue[i]));
    }

    rowNum++;
    if(rowNum<18)
    {
        for(int i = rowNum;i<18;i++)
        {
            model->item(i,0)->setText("");
            model->item(i,1)->setText("");
        }
    }
}

PalletParameterSettingView::~PalletParameterSettingView()
{
    delete ui;
}

void PalletParameterSettingView::showView_slot()
{
    this->show();
    updateConditionSHow(ui->comboBox_index->currentIndex());
}

void PalletParameterSettingView::updateConditionSHow(int index)
{
    std::vector<struct PalletMiddleInfo> configListOut;
    if(communicateNormal->getPalletConditionInfo(configListOut)==1)
    {
     qDebug() << "listCount:" << configListOut.size();
    }

    if(index<configListOut.size())
    {
        palletMiddleInfo = configListOut.at(index);
        palletMiddleInfo.configInfo.stackPointA_nList.resize(D_PATH_DEFAULT_SIZE);
        palletMiddleInfo.configInfo.stackPointR_nList.resize(D_PATH_DEFAULT_SIZE);
        for(int m=0;m<D_PATH_DEFAULT_SIZE;m++)
        {
            palletMiddleInfo.configInfo.stackPointA_nList[m].points.resize(D_APPROACH_DEFAULT_SIZE);
            palletMiddleInfo.configInfo.stackPointR_nList[m].points.resize(D_RETURN_DEFAULT_SIZE);
        }
        palletMiddleInfo.configInfo.stackStylePointInfo.resize(D_STYLE_DEFAULT_SIZE+1);
        updateUiShow(palletMiddleInfo.configInfo);
        on_comboBox_styleType_activated(palletMiddleInfo.configInfo.stackType);
        QMessageBox::information(this, "提示", "参数获取成功!", QMessageBox::Yes );
    }
    else
    {
        QMessageBox::information(this, "提示", "无参数!", QMessageBox::Yes );
    }

}

void PalletParameterSettingView::updateUiShow(StackInfo info)
{
    ui->lineEdit_pathStyleCount->setText(QString::number(info.pathStyleCount));
//    ui->comboBox_index->setCurrentIndex(info.stackNumber);
//    ui->PLIndex_lineEdit->setText(QString::number(info.stackRegisterNumber));
    ui->lineEdit_name->setText(QString::fromStdString(info.stackName));
    ui->type_comboBox->setCurrentIndex(info.stackUpDown);
    ui->increase_lineEdit->setText(QString::number(info.execIncr));
    ui->order_comboBox->setCurrentIndex(info.execOrder);
    ui->direction_comboBox->setCurrentIndex(info.teachOrder);

    ui->palletRowCount_lineEdit->setText(QString::number(info.row));
    ui->palletColumnCount_lineEdit->setText(QString::number(info.col));
    ui->palletLayerCount_lineEdit->setText(QString::number(info.layer));

    if(info.intervalValue.size()>=3)
    {
        ui->RowIntervalValue_lineEdit->setText(QString("%1").arg(info.intervalValue[0]));
        ui->ColumnIntervalValue_lineEdit->setText(QString("%1").arg(info.intervalValue[1]));
        ui->LayerIntervalValue_lineEdit->setText(QString("%1").arg(info.intervalValue[2]));
    }

    if(3<=info.intervalEnable.size())
    {
        if(0 == info.intervalEnable[0])
        {
            ui->rowIntervalEnable_Btn->setStyleSheet(intervalOffPicture);
        }
        else if(1 == info.intervalEnable[0])
        {
            ui->rowIntervalEnable_Btn->setStyleSheet(intervalOnPicture);
        }
        if(0 == info.intervalEnable[1])
        {
            ui->columnIntervalEnable_Btn->setStyleSheet(intervalOffPicture);
        }
        else if(1 == info.intervalEnable[1])
        {
            ui->columnIntervalEnable_Btn->setStyleSheet(intervalOnPicture);
        }
        if(0 == info.intervalEnable[2])
        {
            ui->layerIntervalEnable_Btn->setStyleSheet(intervalOffPicture);
        }
        else if(1 == info.intervalEnable[2])
        {
            ui->layerIntervalEnable_Btn->setStyleSheet(intervalOnPicture);
        }
    }



    ui->approachCount_lineEdit->setText(QString::number(info.stackProximityCount));
    ui->fleeCount_lineEdit->setText(QString::number(info.stackFleeCount));
    ui->styleCount_lineEdit->setText(QString::number(info.stackStyleCount));
    ui->comboBox_styleType->setCurrentIndex(info.stackType);

    if(EM_STACK_AUX_NONE == info.auxiliary)
    {
        ui->auxiliary_checkBox->setChecked(false);
    }
    else if(EM_STACK_AUX_EXIST == info.auxiliary)
    {
        ui->auxiliary_checkBox->setChecked(true);
    }
}

void PalletParameterSettingView::updateView()
{
    updateUiShow(palletMiddleInfo.configInfo);
}


void PalletParameterSettingView::getInput()
{
    palletMiddleInfo.configInfo.stackRegisterNumber = 0;
    palletMiddleInfo.configInfo.pathStyleCount = ui->lineEdit_pathStyleCount->text().toInt();
    palletMiddleInfo.configInfo.stackNumber = ui->comboBox_index->currentIndex()+1;
    palletMiddleInfo.configInfo.stackUpDown = ui->type_comboBox->currentIndex();
    palletMiddleInfo.configInfo.execIncr = ui->increase_lineEdit->text().toInt();
    palletMiddleInfo.configInfo.execOrder = ui->order_comboBox->currentIndex();
    palletMiddleInfo.configInfo.teachOrder = ui->direction_comboBox->currentIndex();

    palletMiddleInfo.configInfo.row = ui->palletRowCount_lineEdit->text().toInt();
    palletMiddleInfo.configInfo.col = ui->palletColumnCount_lineEdit->text().toInt();
    palletMiddleInfo.configInfo.layer = ui->palletLayerCount_lineEdit->text().toInt();
    palletMiddleInfo.configInfo.intervalValue.resize(3);
    palletMiddleInfo.configInfo.intervalValue[0] = ui->RowIntervalValue_lineEdit->text().toFloat();
    palletMiddleInfo.configInfo.intervalValue[1] = ui->ColumnIntervalValue_lineEdit->text().toFloat();
    palletMiddleInfo.configInfo.intervalValue[2] = ui->LayerIntervalValue_lineEdit->text().toFloat();

    palletMiddleInfo.configInfo.stackProximityCount = ui->approachCount_lineEdit->text().toInt();
    palletMiddleInfo.configInfo.stackFleeCount = ui->fleeCount_lineEdit->text().toInt();
    palletMiddleInfo.configInfo.stackStyleCount = ui->styleCount_lineEdit->text().toInt();

    palletMiddleInfo.configInfo.stackType=ui->comboBox_styleType->currentIndex();
    palletMiddleInfo.configInfo.stackName=ui->lineEdit_name->text().toStdString();

}

void PalletParameterSettingView::changeLanguage()
{
    ui->retranslateUi(this);
}


void PalletParameterSettingView::on_rowIntervalEnable_Btn_clicked()
{
    if(1>palletMiddleInfo.configInfo.intervalEnable.size())
    {
        return ;
    }
    if(0 == palletMiddleInfo.configInfo.intervalEnable[0])
    {
        ui->rowIntervalEnable_Btn->setStyleSheet(intervalOnPicture);
        palletMiddleInfo.configInfo.intervalEnable[0] = 1;
    }
    else if(1 == palletMiddleInfo.configInfo.intervalEnable[0])
    {
        ui->rowIntervalEnable_Btn->setStyleSheet(intervalOffPicture);
        palletMiddleInfo.configInfo.intervalEnable[0] = 0;
    }
}

void PalletParameterSettingView::on_columnIntervalEnable_Btn_clicked()
{
    if(2>palletMiddleInfo.configInfo.intervalEnable.size())
    {
        return ;
    }
    if(0 == palletMiddleInfo.configInfo.intervalEnable[1])
    {
        ui->columnIntervalEnable_Btn->setStyleSheet(intervalOnPicture);
        palletMiddleInfo.configInfo.intervalEnable[1] = 1;
    }
    else if(1 == palletMiddleInfo.configInfo.intervalEnable[1])
    {
        ui->columnIntervalEnable_Btn->setStyleSheet(intervalOffPicture);
        palletMiddleInfo.configInfo.intervalEnable[1] = 0;
    }
}

void PalletParameterSettingView::on_layerIntervalEnable_Btn_clicked()
{
    if(3>palletMiddleInfo.configInfo.intervalEnable.size())
    {
        return ;
    }
    if(0 == palletMiddleInfo.configInfo.intervalEnable[2])
    {
        ui->layerIntervalEnable_Btn->setStyleSheet(intervalOnPicture);
        palletMiddleInfo.configInfo.intervalEnable[2] = 1;
    }
    else if(1 == palletMiddleInfo.configInfo.intervalEnable[2])
    {
        ui->layerIntervalEnable_Btn->setStyleSheet(intervalOffPicture);
        palletMiddleInfo.configInfo.intervalEnable[2] = 0;
    }
}

void PalletParameterSettingView::on_auxiliary_checkBox_clicked()
{
    palletMiddleInfo.configInfo.auxiliary=ui->auxiliary_checkBox->isChecked();
}

void PalletParameterSettingView::on_comboBox_index_currentIndexChanged(int index)
{
    updateConditionSHow(index);
}

void PalletParameterSettingView::fleetPointViewPage_slot(int isNext)
{


}

void PalletParameterSettingView::stackPointViewPage_slot(int isNext)
{

}

void PalletParameterSettingView::approchPointViewPage_slot(int isNext)
{


}

void PalletParameterSettingView::stackStylePointPage_slot(int isNext)
{


}


void PalletParameterSettingView::moveToPointSlot(PointPro target)
{
    MoveParameter tmpMoveParameter;
    tmpMoveParameter.moveType = 1;//默认关节方式移动
    tmpMoveParameter.pointType = 0;//点类型
    tmpMoveParameter.index = 0;
    tmpMoveParameter.cntRatio = 0;
    tmpMoveParameter.lineNumber = -1;
    tmpMoveParameter.velocityUnit =0;
    tmpMoveParameter.velocity = 1;
    tmpMoveParameter.targetPoint=target;
    //审核合法
    if(target.positionValue.size() == 0)
    {
        QMessageBox::information(this,QStringLiteral("提示"),QStringLiteral("当前点没有载入点数据"));
        return;
    }


    moveOperation->startPointMove(tmpMoveParameter);
}

void PalletParameterSettingView::moveToPointFinishSlot()
{
    //emit stopMoveToPointSignal();
    moveOperation->stopPointMove();
}


void PalletParameterSettingView::on_pushButton_return_clicked()
{
    hide();
}

void PalletParameterSettingView::on_pushButton_changeConfig_clicked()
{
    getInput();
    int returnInfo;
    //gSOAP通信服务端修改信息
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);

    QMessageBox::information(this, "提示", "设置成功，即刻生效!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_recordPoint_Btn_Approach_clicked()
{
    int index=ui->approachIndex_ComboBox->currentIndex();
    int pathId=ui->comboBox_approachPathIndex->currentIndex();
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    if(index>=palletMiddleInfo.configInfo.stackPointA_nList[pathId].points.size())
    {
        QMessageBox::information(this, "提示", "点个数不一致!", QMessageBox::Yes );
        return;
    }
    palletMiddleInfo.configInfo.stackPointA_nList[pathId].points[index] = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );

}


void PalletParameterSettingView::on_showPoint_Btn_approach_clicked()
{
    int index=ui->approachIndex_ComboBox->currentIndex();
    int pathId=ui->comboBox_approachPathIndex->currentIndex();
    QString comment="接近点"+QString::number(index+1)+"路径样式"+QString::number(pathId+1);
    showPointInfo(comment,palletMiddleInfo.configInfo.stackPointA_nList[pathId].points[index]);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_recordPoint_Btn_flee_clicked()
{
    int index=ui->fleeIndex_ComboBox->currentIndex();
    int pathId=ui->comboBox_fleePathIndex->currentIndex();
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    if(index>=palletMiddleInfo.configInfo.stackPointR_nList[pathId].points.size())
    {
        QMessageBox::information(this, "提示", "点个数不一致!", QMessageBox::Yes );
        return;
    }
    palletMiddleInfo.configInfo.stackPointR_nList[pathId].points[index] = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_moveToPoint_Btn_approach_pressed()
{
    int index=ui->approachIndex_ComboBox->currentIndex();
    int pathId=ui->comboBox_approachPathIndex->currentIndex();
    moveToPointSlot(palletMiddleInfo.configInfo.stackPointA_nList[pathId].points[index]);
}

void PalletParameterSettingView::on_moveToPoint_Btn_approach_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_moveToPoint_Btn_flee_pressed()
{
    int index=ui->fleeIndex_ComboBox->currentIndex();
    int pathId=ui->comboBox_fleePathIndex->currentIndex();
    moveToPointSlot(palletMiddleInfo.configInfo.stackPointR_nList[pathId].points[index]);
}

void PalletParameterSettingView::on_moveToPoint_Btn_flee_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_showPoint_Btn_flee_clicked()
{
    int index=ui->fleeIndex_ComboBox->currentIndex();
    int pathId=ui->comboBox_fleePathIndex->currentIndex();
    QString comment="逃离点"+QString::number(index+1)+"路径样式"+QString::number(pathId+1);
    showPointInfo(comment,palletMiddleInfo.configInfo.stackPointR_nList[pathId].points[index]);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_recordPoint_Btn_btm_clicked()
{
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackPointBTM = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_moveToPoint_Btn_btm_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackPointBTM);
}

void PalletParameterSettingView::on_moveToPoint_Btn_btm_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_showPoint_Btn_btm_clicked()
{
    QString comment="堆栈点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackPointBTM);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_recordPoint_Btn_start_clicked()
{

    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[0].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[0].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[0].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[0].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[0].stackPoint = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_recordPoint_Btn_row_clicked()
{
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[1].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[1].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[1].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[1].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[1].stackPoint = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_recordPoint_Btn_column_clicked()
{
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[2].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[2].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[2].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[2].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[2].stackPoint = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_recordPoint_Btn_layer_clicked()
{
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].stackPoint = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_recordPoint_Btn_aux_clicked()
{
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[4].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[4].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[4].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[4].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[4].stackPoint = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_showPoint_Btn_start_clicked()
{
    QString comment="起点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[0].stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_showPoint_Btn_row_clicked()
{
    QString comment="行点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[1].stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_showPoint_Btn_column_clicked()
{
    QString comment="列点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[2].stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_showPoint_Btn_layer_clicked()
{
    QString comment="层点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[3].stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_showPoint_Btn_aux_clicked()
{
    QString comment="辅助点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[4].stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_moveToPoint_Btn_start_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[0].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_start_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_moveToPoint_Btn_row_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[1].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_row_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_moveToPoint_Btn_column_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[2].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_column_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_moveToPoint_Btn_layer_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[3].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_layer_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_moveToPoint_Btn_aux_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[4].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_aux_released()
{
    moveToPointFinishSlot();
}


void PalletParameterSettingView::setTableText()
{
    model = new QStandardItemModel();
    ui->pointInfo_tableView->setModel(model);
    model->setColumnCount(2);
    ui->pointInfo_tableView->setColumnWidth(0,158);
    ui->pointInfo_tableView->setColumnWidth(1,220);
    ui->pointInfo_tableView->verticalHeader()->hide();
    model->setHeaderData(0,Qt::Horizontal,tr("类型"));
    model->setHeaderData(1,Qt::Horizontal,tr("值"));
    model->setItem(0,0,new QStandardItem(tr("节点类型")));
    model->setItem(1,0,new QStandardItem(tr("点编号")));
    model->setItem(2,0,new QStandardItem(tr("组编号")));
    model->setItem(3,0,new QStandardItem(tr("用户坐标系编号")));
    model->setItem(4,0,new QStandardItem(tr("工具坐标系编号")));
    model->setItem(5,0,new QStandardItem(tr("多解选择;多圈选择")));
    model->setItem(6,0,new QStandardItem(tr("J1")));
    model->setItem(7,0,new QStandardItem(tr("EX1")));
    model->setItem(8,0,new QStandardItem(""));
    model->setItem(9,0,new QStandardItem(""));
    model->setItem(10,0,new QStandardItem(""));
    model->setItem(11,0,new QStandardItem(""));
    model->setItem(12,0,new QStandardItem(""));
    model->setItem(13,0,new QStandardItem(""));
    model->setItem(14,0,new QStandardItem(""));
    model->setItem(15,0,new QStandardItem(""));
    model->setItem(16,0,new QStandardItem(""));
    model->setItem(17,0,new QStandardItem(""));//预先开启18个位置
    for(int i = 0;i<18;i++)
    {
        model->setItem(i,1,new QStandardItem(""));
        model->item(i,0)->setEditable(false);
    }
    model->item(0,1)->setEditable(false);
    model->item(1,1)->setEditable(false);

    if(sixAxisName.size() != D_ROBOT_AXIS_MAX)
    {
        sixAxisName.resize(D_ROBOT_AXIS_MAX);
        sixAxisName[0] = tr("轴值:X");
        sixAxisName[1] = tr("轴值:Y");
        sixAxisName[2] = tr("轴值:Z");
        sixAxisName[3] = tr("轴值:W");
        sixAxisName[4] = tr("轴值:P");
        sixAxisName[5] = tr("轴值:R");
    }
}

void PalletParameterSettingView::on_recordPoint_Btn_Fstyle_clicked()
{
    int index=ui->comboBox_FstyleRow->currentIndex();
    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[index+1].stackPoint = currentPositionDecartOut;

    palletMiddleInfo.configInfo.stackStylePointInfo[index+1].fleeStyleIndex=ui->combox_pointFleePathIndex->currentText().toInt();
    palletMiddleInfo.configInfo.stackStylePointInfo[index+1].approachStyleIndex=ui->combox_pointApproachPathIndex->currentText().toInt();

    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入成功!", QMessageBox::Yes );
}


void PalletParameterSettingView::on_showPoint_Btn_Fstyle_clicked()
{
    QString comment="F样式行点"+ui->comboBox_FstyleRow->currentText();
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[ui->comboBox_FstyleRow->currentIndex()+1]
            .stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_comboBox_styleType_activated(int index)
{
    qDebug()<<"on_comboBox_styleType_activated"<<index;
    switch(index)
    {
    case 4:
        ui->palletColumnCount_lineEdit->setText(QString::number(1));
        ui->palletColumnCount_lineEdit->setEnabled(false);
        ui->stackStylePointInfoB_GBox->setEnabled(false);
        ui->groupBox_stylePointF->setEnabled(true);
        ui->comboBox_approachPathIndex->setEnabled(true);
        ui->comboBox_fleePathIndex->setEnabled(true);
        on_comboBox_FstyleRow_activated(ui->comboBox_FstyleRow->currentIndex());
        break;
    default:
        ui->palletColumnCount_lineEdit->setEnabled(true);
        ui->stackStylePointInfoB_GBox->setEnabled(true);
        ui->groupBox_stylePointF->setEnabled(false);
        ui->comboBox_approachPathIndex->setCurrentIndex(0);
        ui->comboBox_approachPathIndex->setEnabled(false);
        ui->comboBox_fleePathIndex->setCurrentIndex(0);
        ui->comboBox_fleePathIndex->setEnabled(false);
    }
}

void PalletParameterSettingView::on_moveToPoint_Btn_Fstyle_pressed()
{
    int index=ui->comboBox_FstyleRow->currentIndex();
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[index+1].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_Fstyle_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_recordPoint_Btn_FstyleTopLayer_clicked()
{

    PointPro currentPositionDecartOut;
    globalData->getCurrentArmPosition_decart(currentPositionDecartOut);
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer.resize(3);
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[0]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[1]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[3].rowColumnLayer[2]=0;
    palletMiddleInfo.configInfo.stackStylePointInfo[0].stackPoint = currentPositionDecartOut;
    int returnInfo;
    communicateNormal->setPalletConditionInfo(palletMiddleInfo.configInfo,returnInfo);
    QMessageBox::information(this, "提示", "载入顶点成功!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_moveToPoint_Btn_FstyleTopLayer_pressed()
{
    moveToPointSlot(palletMiddleInfo.configInfo.stackStylePointInfo[0].stackPoint);
}

void PalletParameterSettingView::on_moveToPoint_Btn_FstyleTopLayer_released()
{
    moveToPointFinishSlot();
}

void PalletParameterSettingView::on_showPoint_Btn_layer_FstyleTopLayer_clicked()
{
    QString comment="F样式顶层点";
    showPointInfo(comment,palletMiddleInfo.configInfo.stackStylePointInfo[0]
            .stackPoint);
    ui->tabWidget->setCurrentIndex(4);
}

void PalletParameterSettingView::on_button_setPointPathIndex_clicked()
{
    int index=ui->comboBox_FstyleRow->currentIndex();
    palletMiddleInfo.configInfo.stackStylePointInfo[index+1].fleeStyleIndex=ui->combox_pointFleePathIndex->currentText().toInt();
    palletMiddleInfo.configInfo.stackStylePointInfo[index+1].approachStyleIndex=ui->combox_pointApproachPathIndex->currentText().toInt();
    QMessageBox::information(this, "提示", "点路径样式设置OK!", QMessageBox::Yes );
}

void PalletParameterSettingView::on_comboBox_FstyleRow_activated(int index)
{

    ui->combox_pointFleePathIndex->setCurrentIndex(palletMiddleInfo.configInfo.stackStylePointInfo[index+1].
            fleeStyleIndex-1);
    ui->combox_pointApproachPathIndex->setCurrentIndex(palletMiddleInfo.configInfo.stackStylePointInfo[index+1].
            approachStyleIndex-1);
}
